package com.jrx.anytxn.transaction.job.autoPayment.step;

import com.jrx.anytxn.transaction.entity.BtAutoPaymentList;
import com.jrx.anytxn.transaction.mapper.ext.ExtBtAutoPaymentListMapper;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.batch.item.ItemWriter;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 第三次批扣初始化数据保存入库
 *
 * @Author yhy
 * @Date 2023/4/25 11:02
 */
@Service
public class AutoPaymentThirdInitWriter implements ItemWriter<BtAutoPaymentList>  {

    @Resource
    private ExtBtAutoPaymentListMapper extBtAutoPaymentListMapper;

    @Override
    public void write(List<? extends BtAutoPaymentList> items) {
        if(CollectionUtils.isNotEmpty(items)){
            for (BtAutoPaymentList item : items){
                if(!ObjectUtils.isEmpty(item)){
                    extBtAutoPaymentListMapper.insert(item);
                }
            }
        }
    }
}
